#{extends 'main.html' /}
#{set title:'Candidate Pairs' /}

<div>Click a submission to toggle its files</div>
<ul>
#{list items:cases, as:'c'}
	<li id="${c.id}_row">
		<div>Percentage: ${c.percentage} <a href="javascript:compareSubmissions(${c.s1.id}, ${c.s2.id});">compare files</a></div>
		<div><a href="javascript:;" onclick="$('#${c.s1.id}').toggle();" class="">${c.s1}</a> (by ${c.s1.student.username} @ <span class="formatTime">${c.s1.time}</span>)</div>
		<div id="${c.s1.id}" style="display:none;"><a href="/download/submission?id=${c.s1.id}">${c.s1.file.filename}</a></div>
		<div><a href="javascript:;" onclick="$('#${c.s2.id}').toggle();" class="">${c.s2}</a> (by ${c.s2.student.username} @ <span class="formatTime">${c.s2.time}</span>)</div>
		<div id="${c.s2.id}" style="display:none;"><a href="/download/submission?id=${c.s2.id}">${c.s2.file.filename}</a></div>
		<div id="${c.id}_actions">
			<form onsubmit="return process_cheating_case(${c.id});">
				<select name="action_${c.id}">
					<option value="0">Blame neither</option>
					<option value="1">Blame ${c.s1.student.username}</option>
					<option value="2">Blame ${c.s2.student.username}</option>
					<option value="3">Blame both</option>
				</select> <span class="tiny_info">Comment:</span> <input type="text" id="comment_${c.id}" />* <span class="tiny_info">CC: (op)</span> <input type="text" name="cc_${c.id}" /> <input type="submit" value="Process Case" />
			</form>
		</div>
	</li>
#{/list}
</ul>
<pre id="comparisonPre"></pre>
<input type="checkbox" id="confirm" checked /> Confirm before processing
<div class="tiny_info">Confirming a cheating case is a very serious action. Really.</div>
				<div class="tiny_info">Seperate CCs with a comma. They're auto-trimmed so you don't need to worry about extra whitespaces.</div> 
<script type="text/javascript">
function process_cheating_case(cId) {
	if ($('#confirm').is(":checked") && !confirm('Confirm processing this cheating case')) {
		return false;
	}
	$.post('/submissions/processcase',
			{caseId:cId, action:$('#action_'+cId+':selected').val(), comment: $('#comment_'+cId).val(), cc:$('#cc_'+cId).val()},
			function() {
				$('#'+cId+'_row').effect('highlight').fadeOut();
			});
	return false;
}
</script>